<?php
	@$cmd = $_GET['cmd'];
	@$localize = $_POST['localize'];
	$INCLUDE_PATH = '';
	$TITLE = '';
	$NAVIGATIVE = '';
	$index_active = '';
	$intro_active = '';
	$prod_active = '';
	$proj_active = '';
	$cont_active = '';
	
	$vi_active = '';
	$en_active = '';
	
	include_once('libs/htdu_core.php');
	include_once('libs/multi_language.php');
	session_start();
	
	if(!isset($_COOKIE["localize"]))
	{
		setcookie("localize", "vi", time()+(3600*24*30));
		header('Location: '.$_SERVER['REQUEST_URI'], true) ;
	}
	else
	{
		if(!isset($_SESSION["multi_langs"]))
		{
			multi_language::get_instance()->load_language($_COOKIE["localize"]);
			$_SESSION["multi_langs"] = multi_language::get_instance();
		}
	}
	
	if(isset($localize))
	{
		setcookie("localize", $localize, time()+(3600*24*30));
		unset($_SESSION["multi_langs"]);
		header('Location: '.$_SERVER['REQUEST_URI'], true) ;
	}
	
	$MULTI_LANG = $_SESSION["multi_langs"];
	$LOCAL = $_COOKIE['localize'];
	if($_COOKIE['localize'] == 'en')
		$en_active = 'active';
	else
		$vi_active = 'active';
	
	$exec_mysql = new execute_mysql_query();
	$search_val = $MULTI_LANG->get_word_by_key('search_hint');
	
	if(!isset($_SESSION['visit_count']))
	{
		$_SESSION['visit_count'] = 'DKT Group';
		$exec_mysql->execute("update extra set val_vi = val_vi+1, val_en = val_en+1 where ref = 'visit_count'", 0);
	}
	
	switch($cmd)
	{
		case 'index':
			$TITLE = $MULTI_LANG->get_word_by_key('home');
			$NAVIGATIVE = $TITLE;
			$INCLUDE_PATH = 'subs/index.php';
			$index_active = 'class = "active"';
			break;
		case 'intro':
			$TITLE = $MULTI_LANG->get_word_by_key('intro');
			$NAVIGATIVE = $TITLE;
			$INCLUDE_PATH = 'subs/intro.php';
			$intro_active = 'class = "active"';
			break;
		case 'product':
			$TITLE = $MULTI_LANG->get_word_by_key('product');
			$NAVIGATIVE = $TITLE;
			@$cat = $_GET['cat'];
			if($cat != '')
			{
				$cat = str_replace('-','',$cat);
				$cat_name = $exec_mysql->execute("select name_$LOCAL from category where id = $cat", 1);
				$NAVIGATIVE = '<a href="san-pham.html">Sản phẩm</a> » '.$cat_name;
			}
			
			$INCLUDE_PATH = 'subs/product.php';
			$prod_active = 'class = "active"';
			break;
		case 'project':
			$TITLE = $MULTI_LANG->get_word_by_key('project');
			$NAVIGATIVE = $TITLE;
			$INCLUDE_PATH = 'subs/project.php';
			$proj_active = 'class = "active"';
			break;
		case 'contact':
			$TITLE = $MULTI_LANG->get_word_by_key('contact');
			$NAVIGATIVE = $TITLE;
			$INCLUDE_PATH = 'subs/contact.php';
			$cont_active = 'class = "active"';
			break;
		case 'search':
			$TITLE = $MULTI_LANG->get_word_by_key('search');
			$NAVIGATIVE = $TITLE;
			$INCLUDE_PATH = 'subs/search.php';
			$search_val = $_GET['q'];
			break;
		case 'detail-product':
			@$id_prod = $_GET['id'];
			@$id_cat = $_GET['cat'];
			$TITLE = 'Chi tiết sản phẩm';
			$NAVIGATIVE = 'Sản phẩm';
			$INCLUDE_PATH = 'subs/detail-product.php';
			if($id_cat != '' && $id_prod != '')
			{
				$cat_name = $exec_mysql->execute("select name_$LOCAL from category where id = $id_cat", 1);
				$title_prod = $exec_mysql->execute("select title_$LOCAL from node where id = $id_prod", 1);
				$TITLE = $title_prod;
				$NAVIGATIVE = '<a href="san-pham.html">'.$MULTI_LANG->get_word_by_key('product').'</a> » <a href="san-pham-'.$id_cat.'.html">'.$cat_name.'</a> » '.$title_prod;
			}
			$prod_active = 'class = "active"';
			break;
		case 'detail-project':
			@$id_proj = $_GET['id'];
			$TITLE = 'Chi tiết dự án';
			$NAVIGATIVE = 'Dự án';
			$INCLUDE_PATH = 'subs/detail-project.php';
			if($id_proj != '')
			{
				$title_proj = $exec_mysql->execute("select title_$LOCAL from node where id = $id_proj", 1);
				$TITLE = $title_proj;
				$NAVIGATIVE = '<a href="du-an.html">'.$MULTI_LANG->get_word_by_key('project').'</a> » '.$title_proj;
			}
			$proj_active = 'class = "active"';
			break;
		case 'service':
			$TITLE = $MULTI_LANG->get_word_by_key('service');
			$NAVIGATIVE = $TITLE;
			$INCLUDE_PATH = 'subs/service.php';
			break;
		default:
			$TITLE = $MULTI_LANG->get_word_by_key('home');
			$NAVIGATIVE = $TITLE;
			$INCLUDE_PATH = 'subs/index.php';
			$index_active = 'class = "active"';
			break;
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="css/layout.css" type="text/css" />
        <link rel="stylesheet" href="css/control.css" type="text/css" />
        <script type="text/javascript" src="js/jquery-1.5.2.min.js"></script>
        <script type="text/javascript" src="http://cdn.dev.skype.com/uri/skype-uri.js"></script>
        <script type="text/javascript" src="js/jquery.cycle.all.latest.js"></script>
        <script type="text/javascript">var default_search = '<?php echo $search_val; ?>';</script>
		<script type="text/javascript" src="js/master_script.js"></script>
        <title><?php print $TITLE; ?> - Partition WC</title>
    </head>
    
    <body>
        <div class="top">
        	<span class="span-support-online"><?php echo $MULTI_LANG->get_word_by_key('support_online'); ?>:</span>
            <!--Yahoo-->
            <div class="yahoo">
            	<?php
                	$yahoo = $exec_mysql->execute("select val_$LOCAL from extra where ref = 'yahoo'", 1);
					$skype = $exec_mysql->execute("select val_$LOCAL from extra where ref = 'skype'", 1);
					$hot_line = $exec_mysql->execute("select val_$LOCAL from extra where ref = 'hot_line'", 1);
					$hot_email = $exec_mysql->execute("select val_$LOCAL from extra where ref = 'email'", 1);
					print('<a href="ymsgr:sendIM?'.$yahoo.'"><img src="http://opi.yahoo.com/online?u='.$yahoo.'&m=g&t=1"/></a>')
				?>
            </div>
            
            <!--Skype-->
            <div id="SkypeButton_Chat" class="skype">
				<script type="text/javascript">
                	Skype.ui({
                    	"name": "chat",
                    	"element": "SkypeButton_Chat",
                    	"participants": ["<?php print $skype; ?>"]
                	});
                </script>
            </div>
            <div class="divider-top">|</div>
            <!--Hot-line-->
            <div class="hot-line">
            	Hot-line: <?php print $hot_line; ?>
            </div>
             <div class="divider-top">|</div>
            <!--Email-->
            <div class="hot-email">
            	Email: <?php print $hot_email; ?>
            </div>
            <!--Languages-->
            <div class="divider-top">|</div>
            <div class="lang">
            	<form id="lan" method="post">
                	<input type="hidden" name="localize" id="localize" />
                </form>
                
            	<span class="<?php echo $vi_active;?> flag-vn" id="set-vi">Tiếng Việt</span> 
                <span class="<?php echo $en_active;?> flag-en" id="set-en">English</span>
            </div>
            <!--Search box-->
            <div class="search-box">
            	<input name="q" class="textbox-search" value="<?php print htmlspecialchars($search_val); ?>" id="txt-keyword" />
            </div>
        </div>
        <div class="logo-menu">
        	<div class="logo-menu-containt">
            	<div class="logo"><a href="."><img src="img/vach-ngan-logo.png" title="Partition WC" /></a></div>
                <ul class="ul-menu">
                	<li <?php print $cont_active; ?>><a href="lien-he.html" <?php print $cont_active; ?>><?php echo $MULTI_LANG->get_word_by_key('contact'); ?></a></li>
                	<li <?php print $proj_active; ?>><a href="du-an.html" <?php print $proj_active; ?>><?php echo $MULTI_LANG->get_word_by_key('project'); ?></a></li>
                    <li id="men-prod" <?php print $prod_active; ?>>
                    	<a href="san-pham.html" <?php print $prod_active; ?>><?php echo $MULTI_LANG->get_word_by_key('product'); ?></a>
                    	<!--Product sub menu-->
					<?php
                        $result = $exec_mysql->execute("select * from category order by id asc", 0);
						$i = 0;
						echo '<ul class="sub-product-menu" id="sub-product-menu">';
						while($row = mysql_fetch_array($result))
						{
							if($i == 0)
								echo '<li class="first"><a href="'.$row['id'].'-san-pham.html">'.$row['name_'.$LOCAL].'</a></li>';
							else
								echo '<li><a href="'.$row['id'].'-san-pham.html">'.$row['name_'.$LOCAL].'</a></li>';
							$i++;
						}
						echo '</ul>';
                    ?>   
                    </li>
                    <li <?php print $intro_active; ?>><a href="gioi-thieu.html" <?php print $intro_active; ?>><?php echo $MULTI_LANG->get_word_by_key('intro'); ?></a></li>
                    <li <?php print $index_active; ?>><a href="trang-chu.html" <?php print $index_active; ?>><?php echo $MULTI_LANG->get_word_by_key('home'); ?></a></li>
                </ul>
            </div>
        </div>
        <div class="slideshow" id="slideshow">
        	<?php
            	foreach (glob("pics/*.jpg") as $filename)
				{
   					print('<img src="'.$filename.'" />');
				}
			?>
        </div>
        <div class="body-site">
        	<div class="body-site-top"></div>
            <div class="body-site-middle">
            	<!-- Navigative -->
                <div class="navigative">
                	<span class="span-nav"><?php print $NAVIGATIVE; ?></span>
                </div>
                <!-- Body containt -->
                <div class="body-containt">
                	<?php include_once($INCLUDE_PATH); ?>
                </div>
            </div>
            <div class="body-site-bottom"></div>
            <?php
            	$footer = $exec_mysql->execute("select val_$LOCAL from extra where ref = 'footer'", 1);
				$visit_cout = $exec_mysql->execute("select val_$LOCAL from extra where ref = 'visit_count'", 1);
				print $footer.'<br />Develop by <a href="http://datmuiinfo.com" target="_blank">DKT Group</a> | ';
				echo $MULTI_LANG->get_word_by_key('visit_count').': '.$visit_cout;
			?>
        </div>
    </body>
</html>